
//License Information
/*
    Copyright 2010 Jozsef Jantek

    This file is part of HunterTC.

    HunterTC is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    HunterTC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with HunterTC.  If not, see <http://www.gnu.org/licenses/>.
*/

package huntertc;


public class Combat_Event
{
    public int time=0;
    public Shot shot;
    public boolean shott=false, dot=false;
    public Combat_Event prev=this;
    public Combat_Event next=this;

Combat_Event(){}

Combat_Event(int stime, Shot sspell)
{
    time=stime;
    shot=sspell;
    shott=true;
}

public void AddShotEvent(int stime, Shot sspell)
{
    Combat_Event ev=new Combat_Event();
    ev.time=stime;
    ev.prev=this;
    ev.next=this.next;
    ev.shot=sspell;

    ev.shott=true;

    while(ev.next.shot.name!="Combat"&&ev.next.time<=ev.time)
    {
        ev.prev=ev.next;
        ev.next=ev.next.next;
    }
    ev.prev.next=ev;
    ev.next.prev=ev;  
}

public void AddDotEvent(int stime, Shot sspell)
{
    Combat_Event ev=new Combat_Event();
    ev.time=stime;
    ev.prev=this;
    ev.next=this.next;
    ev.shot=sspell;

    ev.dot=true;

    while(ev.next.shot.name!="Combat"&&ev.next.time<=ev.time)
    {
        ev.prev=ev.next;
        ev.next=ev.next.next;
    }
    ev.prev.next=ev;
    ev.next.prev=ev;
}

public void DelEvent()
{
    prev.next=next;
    next.prev=prev;
}

public void Reset()
{
    shot= new Shot();
    this.next=this;
    this.prev=this;
}

public void ShowAll()
{
    if(next.shot.name!="Combat")
    {
        System.out.println("\n"+next.shot.name+"   "+next.time);
        next.ShowAll();
    }
}
}